#pragma once

#include "Types.h"
#include <irrXML.h>


#include "RefCount.h"


using namespace irr;
using namespace core;
using namespace io;

class CGameManager;

class CSceneObject
{
public:
	CSceneObject();
	CSceneObject(IFileReadCallBack *file);
	~CSceneObject();

	// handler functions
	virtual void handleEvents(CGameManager *engine);
    virtual void passTime(f32);
	void doMovement(f32 frameDeltaTime);

	virtual bool collisionCallback(CSceneObject *obj);
	virtual __inline E_GAMEOBJECT_TYPE getType(){ return E_GAMEOBJECT_TYPE::SceneObject; }

	// accessors  and helper math functions
	 vector3df		getTargetBearing(void);
	 vector3df		getTargetBearing(vector3df target);
	 void			setBearing(f32 x, f32 y) ;
	 vector3df		getVelocityAtTarget(vector3df target, f32 speed);
	 vector3df		getVelocityAtTarget(f32 speed);
	 void			setVelocityAtTarget(vector3df target, f32 speed);
	 void			setVelocityAtTarget(f32 speed);
	vector3df		getRotationAtTarget(void);
	 vector3df		getRotationAtTarget(vector3df target);
	void			setRotationAtTarget(void);
	 void			setRotationAtTarget(vector3df target);
	void			setVelocity(vector3df value);
	vector3df		getVelocity(void);
	void			setRotation(vector3df value);
	vector3df		getRotation(void);
	vector3df		getPosition(void);
	void			setPosition(vector3df value);
	f32				getSpeed(void);
	virtual	 void	setSceneNode(ISceneNode *node);
	 static s32		getUniqueObjectID(void);

	// simple functions
	void move(vector3df vel);
	void rotate(vector3df rot);
	void turn(f32 rot);
	void pitch(f32 rot);
	void roll(f32 rot);

	// helpers
	void deserialize(char *file);
	void deserialize(char *buffer, long length);
	void deserialize(IFileReadCallBack *file);



	DECLARE_MEMBER(s32, ID)
	DECLARE_MEMBER(char*, XmlID)
	DECLARE_MEMBER(IPhysxObject*, PhysxObject)
	DECLARE_MEMBER(IPhysxMesh*, PhysxMesh)
	DECLARE_MEMBER(CSceneObject*, Target)
	DECLARE_MEMBER(IMesh*, Mesh)
	DECLARE_MEMBER(f32, Acceleration)
	DECLARE_MEMBER(char*, MeshPath)
	DECLARE_GET_MEMBER(ISceneNode*, SceneNode)
	DECLARE_GET_FLAG_MEMBER(bool, isDestroyed)
};
